<?php
/**
 * Created by PhpStorm.
 * User: Qch
 * Date: 2016/8/14
 * Time: 7:25
 */

return [
    // 常量定义
    \J\Application::KEY_CONSTANT => [
        '__STATICS__'  => '/statics',
    ],

    // 命名空间定义
    \J\Application::KEY_NAMESPACE => [
        DEFAULT_MODULE_NAMESPACE => DEFAULT_MODULE_DIR
    ],

    // 服务定义
    \J\Application::KEY_SERVICE => [
        // 模块元素创建器
        'Element' => '\J\Art\Poem\Element\ElementFactory',
        'Engine' => '\J\UI\Engine\Thinkphp',
    ],

    // IOC定义
    \J\Application::KEY_OBJECT => [
        // 存储器/缓存器
        'Orm' => '\J\Storage\ORM',
        'File' => '\J\Storage\FilePersister',
        'FileCache' => '\J\Storage\FileCache',
        'Memcached' => '\J\Storage\Memcached',
        'Synchronizer' => '\J\Storage\Synchronizer',
    ],

    // 路由定义
    \J\Application::KEY_ROUTER => [
        // 路由元定义
        \J\Util\Router::CFG_KEY_ENTITY =>[
            'module'     => '[A-Za-z]+',
            'controller' => '[A-Za-z]+',
            'action'     => '[A-Za-z]+',
            'id'         => '[0-9]+',
            'abc'        => '[A-Za-z]+',
            'pairs'      => '[/A-Za-z0-9]+',
            'command'    => '[A-Za-z]+'
        ],
        // 路由规则定义
        \J\Util\Router::CFG_KEY_RULE     =>[
            ':module/:controller/:action/:id' => [],
            ':module/:controller/:action/:pairs' => [],
            ':module/:controller/:action' => [],
            ':module/:controller' => ['action'=>'index'],
            ':command$'=>[],
            '$'=> ['module'=>'index','controller'=>'index','action'=>'index'],
        ],
        // 自定义路由元解析方法
        \J\Util\Router::CFG_KEY_CALLBACK => ['pairs' => 'vars_form_path'],
        // 意图定义
        \J\Util\Router::CFG_KEY_INTENT => [
            'Login' => ['module' => 'UserCenter', 'controller' => 'Login', 'action' => 'Login'],
            'Resource' => ['module' => 'UserCenter', 'controller' => 'Inner', 'action' => 'Resource']
        ],
    ],

    // 模块元素创建服务参数
    'Element' => [
        'switch' => [
            'type'    => \J\Schema\Syntax::VALUE_BOOL,
            'default' => 0,
            'holder'  => 'switch',
            'options' => ['关闭', '开启']
        ],
        'select' => [
            'type'    => \J\Schema\Syntax::VALUE_INT | \J\Schema\Syntax::VALUE_SELECT,
            'holder'  => 'select'
        ],
        'text' => [
            'type' => \J\Schema\Syntax::VALUE_TEXT,
            'holder'  => 'textarea'
        ],
        'html' => [
            'type' => \J\Schema\Syntax::VALUE_TEXT,
            'holder'  => 'html'
        ],
        'email' => [
            'type'    => \J\Schema\Syntax::VALUE_STRING,
            'valid'   => [['type'=>'email']],
            'holder'  => 'email'
        ],
        'mobile' => [
            'type'    => \J\Schema\Syntax::VALUE_STRING,
            'holder'  => 'mobile'
        ],
    ],
    // 调试信息处理参数
    'Debugger' => [
        'template' => DEFAULT_VIR . '/trace.php.tpl',
    ],
];